using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Com.AlbLab.GEP.Services;
using Com.AlbLab.GEP.Domain;
using Com.AlbLab.GEP.Security;
using Com.AlbLab.GEP.Services.Impl;



namespace common.pages
{
	public partial class BasePage : System.Web.UI.Page
	{
        public static ServiceFactory Services = new ServiceFactory();

        private const string MSG_SESSION_KEY = "EUIDFXJKDNDUD78404KRN7FYUCFWIDK";
        private Info _info;
        protected System.Web.UI.WebControls.Panel InfoBox;
        
        public Info info
        {
            get
            {
                return _info;
            }
            set
            {
                _info = value;
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            if (Session[MSG_SESSION_KEY] != null) this._info = (Info)Session[MSG_SESSION_KEY];
            else
            {
                _info = new Info();
                Session.Add(MSG_SESSION_KEY, _info);
            }
            base.OnLoad(e);
        }

		protected virtual void Page_PreRender(object sender, EventArgs e)
		{
            Master myMaster = (Master)this.Master;

            if (info != null && info.messageCount() > 0)
            {
                string msg = info.renderMessage();
                myMaster.ShowMessageList(msg, true);
            }
            Session.Remove(MSG_SESSION_KEY);
		}

		protected void Page_Error(object sender, EventArgs e)
		{
            //Exception e0 = Context.Error;
            //throw ;
		}

		protected override void OnPreInit(EventArgs e)
		{
			base.OnPreInit(e);

			
				SessionManager<string>.set(SessionKeys.THEME_SELEZIONATO, "asm");
				Page.Theme = (string)SessionManager<string>.get(SessionKeys.THEME_SELEZIONATO);
			
		}


        
	
    }
}
